<template>
	<view class="container">
		<textarea style="background-color:#f6f6f6;height: 23vh;width: 100%;border-radius: 10px;" name="" id=""
			cols="100" rows="10" placeholder="请输入..." v-model="form.yj"></textarea>
    <text style="padding: 5px 0">请在下方签字</text>
    <autograph style="height: 58vh;border: 1px solid #d7cccc;border-radius: 8px" @fj="fileUrl"></autograph>
		<div class='butt'>
			<u-button type="primary" text="通 过" @click="submit" class='but'></u-button>
		</div>
	</view>
</template>

<script>
	import autograph from '../../autograph/autograph.vue'
	import{workSubmitAPI} from '@/api/api.js'
	export default {
		data() {
			return {
				form: {
					list: [],
					file: {},
          ysqmtp:'',
          yj:''
				}
			}
		},
		components: {
			autograph
		},
		onLoad(option) {
			this.form.list = option.form
			this.form.file = option.file
		},
		mounted() {
			this.form.list = JSON.parse(this.form.list)
			this.form.file = JSON.parse(this.form.file)
		},
		methods: {
      fileUrl(val){
       this.form.ysqmtp= val
      },
			submit() {
        if (this.form.ysqmtp!==""){
          let data = {
            yj:this.form.yj,
            ysqmtp:this.form.ysqmtp
          }
          workSubmitAPI(this.form.list.id,1,data).then((r)=>{
            console.log(r)
            if (r.code === 200){
              uni.showToast({
                icon: 'success',
                duration: 2000,
                position:'top',
                title: `验收已通过`
              });
              setTimeout((e) => {
              	uni.reLaunch({
              		url:'/pages/home/home'
              	})
              }, 2000)
            }
          })
        }else {
          uni.showToast({
            icon: 'error',
            duration: 2000,
            position:'top',
            title: `请先签字保存`
          });
        }
        console.log(this.form)
			}
		}
	}
</script>

<style lang="scss">
	.container {
		padding: 30rpx;
	}

	.butt {
		margin-top: 50rpx;
	}
</style>
